from es import setplayerprop, getplayerprop
from superdice.libs.diceConfigs import configFile
from superdice.superdice import registerRoll, unregisterRoll, players

def es_map_start(ev):
    cfgData.execute()

def unload():
    unregisterRoll(diceRoll)

def player_spawn(ev):
    players[ev['userid']]['longjump'] = False

def player_jump(ev):
    userid = ev['userid']
    if not players[userid]['longjump']:
        return

    newMulti = float(multi)
    vec = map(str, [getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]') * newMulti, getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]') * newMulti, 20.0])
    setplayerprop(userid, 'CBasePlayer.localdata.m_vecBaseVelocity', ','.join(vec))

def diceRoll(userid, player, eplayer):
    players[userid]['longjump'] = True

cfgData = configFile('dice_longjump')
multi = cfgData.cvar('superdice_cfg_longjump_multiplier', 1.3, 'What is the multiplier for the longjump?')
cfgData.write()
cfgData.execute()

registerRoll(diceRoll, 'longjump')
